package com.midou.administration.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.midou.administration.bo.DishTypeBo;
import com.midou.administration.bo.DishTypePagination;
import com.midou.administration.entity.DishType;
import com.midou.administration.mapper.DishTypeMapper;
import com.midou.administration.service.DishTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author MrChen
 * @since 2021-03-24
 */
@Service
public class DishTypeServiceImpl implements DishTypeService {

        @Autowired
       private DishTypeMapper dishTypeMapper;

        public Page<DishType> findAll(DishTypePagination dishTypePagination){
          List<DishType> findAllList = dishTypeMapper.findAll(dishTypePagination.getPage());
          dishTypePagination.getPage().setRecords(findAllList);
          return dishTypePagination.getPage();
        }

        public int addDishType(DishType dishType){
          int istCount = dishTypeMapper.addDishType(dishType);
          return istCount ;
        }

        public int delDishType(int id){
          int delCount = this.dishTypeMapper.delDishType(id);
          return delCount ;
        }

        public int updDishTypeName(DishType dishType){
          int updCount = this.dishTypeMapper.updDishTypeName(dishType);
          return updCount ;
        }

        public int judgmentDishTypeName(String dishTypeName){
          int count = this.dishTypeMapper.judgmentDishTypeName(dishTypeName);
          return count;
        }

        /**
         * 查询属于这个商家的分类
         * @param businessId  商家id
         * @return  该商家的分类集合
         */
        @Override
        public List<DishType> queryBybusiness(Integer businessId) {
            return this.dishTypeMapper.queryBybusiness(businessId);
        }

      /**
       * 商品分类查看口味和菜品分类页面
       */
      public List<DishTypeBo> query(){
        return dishTypeMapper.qureyall();
      }
}
